package org.bulu.project.system.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.bulu.project.system.model.entity.UserVideo;

import java.util.List;


@Mapper
public interface UserVideoMapper{
    @Delete("delete from user_video where vid = #{videoId}")
    Integer deleteUserVideo(Integer videoId);

    @Select("select * from user_video where uid=#{uid} and love=#{love}")
    List<UserVideo> getVidList(@Param("uid") Integer uid, @Param("love") Integer love);


    @Select("select vid from user_video where uid=#{uid} and love=#{love}")
    List<Integer> getList(@Param("uid") Integer uid, @Param("love") Integer love);

    /**
     * 点赞或点踩，返回更新后的信息
     * @param uid   用户ID
     * @param vid   视频ID
     * @param isLove    赞还是踩 true赞 false踩
     * @param isSet     设置还是取消  true设置 false取消
     * @return  更新后的信息
     */
   void setLoveOrUnlove(@Param("uid") Integer uid,@Param("vid") Integer vid, @Param("isLove")boolean isLove, @Param("isSet")boolean isSet);

    /**
     * 根据用户ID和视频ID获取最新的 UserVideo 实体
     * @param uid 用户ID
     * @param vid 视频ID
     * @return 最新的 UserVideo 实体
     */
    @Select("SELECT * FROM user_video WHERE uid = #{uid} AND vid = #{vid}")
    UserVideo getUserVideoByUidAndVid(@Param("uid") Integer uid,@Param("vid") Integer vid);

    /**
     * 收藏或取消收藏
     * @param uid   用户ID
     * @param vid   视频ID
     * @param isCollect 是否收藏 true收藏 false取消
     */
    void collectOrCancel(@Param("uid")Integer uid, @Param("vid")Integer vid,@Param("collect") boolean isCollect);


    void updateCollectStatus(@Param("uid")Integer uid, @Param("vid")Integer vid, @Param("collect")int isCollect);
}
